const bodyParser = require('koa-bodyparser')
const koaBody = require('koa-body')
const cors = require('koa2-cors')
const static = require('koa-static-server')
const path = require('path')

module.exports = app => {
  app.use(static({
    rootDir: path.resolve(__dirname, '../', 'resources/upload'),
    rootPath: '/upload'
  }))
  app.use(static({
    rootDir: path.resolve(__dirname, '../', 'resources/images'),
    rootPath: '/images'
  }))
  app.use(cors())
  app.use(bodyParser())
  app.use(koaBody({
    multipart: true,
    formidable: {
      maxFileSize: 200 * 1024 * 1024	// 设置上传文件大小最大限制，默认2M
    }
  }))

}
